home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 7 / Apprentice-Release7.iso / Source Code / C / Applications / µSim 1.1 / FabLibsƒ / Internet.c < prev    next >
Encoding:
C/C++ Source or Header  |  1997-04-23  |  3.4 KB  |  143 lines  |  [TEXT/CWIE]

  1. #ifndef __MOREFILESEXTRAS__
  2. #include <MoreFilesExtras.h>
  3. #endif
  4.  
  5. #include    "UtilsSys7.h"
  6. #include    "FabLibResIDs.h"
  7. #include    "Independents.h"
  8. #include    "Internet.h"
  9.  
  10. static ICError MyICLaunchURL(ICInstance inst, short STRid);
  11.  
  12. #pragma segment Main
  13.  
  14. void InternetLaunch(ICInstance inst, ICError *icErr, ModalFilterProcPtr filterProc, AEIdleProcPtr IdleFunct, short urlWanted)
  15. {
  16. Str31    errorStr;
  17. ICError    locICErr;
  18.  
  19. if (inst) {
  20.     *icErr = MyICLaunchURL(inst, urlWanted);
  21. //    UnloadSeg(MyICLaunchURL);
  22.     }
  23. locICErr = *icErr;
  24. if (locICErr) {
  25.     switch (locICErr) {
  26.         case icPrefNotFoundErr:
  27.             (void)StopAlert_AE(kALRT_ICMISSINGHELPER, filterProc, IdleFunct);
  28.             break;
  29.         default:
  30.             NumToString(locICErr, errorStr);
  31.             ParamText(errorStr, nil, nil, nil);
  32.             (void)StopAlert_AE(kALRT_INTERNETCONFIG, filterProc, IdleFunct);
  33.         }
  34.     }
  35. }
  36.  
  37.  
  38. ICError SetCorrectFileType(const ICMapEntry *entry, const FSSpecPtr downloaded_file, ScriptCode theScript,
  39.                             Boolean needSetFileType)
  40. {
  41. FInfo    info;
  42. Handle    tempResource;
  43. OSErr    err = noErr;
  44.  
  45. if (needSetFileType) {
  46.     err = FSpGetFInfoCompat(downloaded_file, &info);
  47.     if (err == noErr) {
  48.         info.fdType = entry->file_type;
  49.         info.fdCreator = entry->file_creator;
  50.         err = FSpSetFInfoCompat(downloaded_file, &info);
  51.         if (err == noErr) {
  52.             (void) BumpDate(downloaded_file->vRefNum, downloaded_file->parID, nil);
  53.             if (FinderIsFront())
  54.                 PostEvent(osEvt, 0x01000003); // send a resume event
  55.             }
  56.         }
  57.     }
  58. if (StrLength(entry->creator_app_name)) {
  59.     tempResource = (Handle)NewString(entry->creator_app_name);
  60.     if (tempResource)
  61.         err = AddSTRHand2Doc(downloaded_file, entry->file_creator, entry->file_type, (StringHandle)tempResource, theScript);
  62.     }
  63.  
  64. return err;
  65. }
  66.  
  67. #pragma segment Internet
  68.  
  69. ICError MyICLaunchURL(ICInstance inst, short STRid)
  70. {
  71. StringHandle    theString;
  72. long    selStart, selEnd;
  73. const short    nullstr = 0;    // otherwise IC 1.1 will crash (doesn't like odd-aligned strings)
  74. ICError    err;
  75.  
  76. if (theString = GetString(STRid)) {
  77.     selStart = 0L;
  78.     selEnd = **theString;
  79.     HLockHi((Handle) theString);
  80.     err = ICLaunchURL(inst, (ConstStr255Param)&nullstr, (Ptr)*theString + 1, selEnd, &selStart, &selEnd);
  81.     HUnlock((Handle) theString);
  82. //    UnloadSeg(ICLaunchURL);
  83.     }
  84. else
  85.     err = ResError();
  86.  
  87. return err;
  88. }
  89.  
  90. ICError MyICLaunchURLText(ICInstance inst, Ptr s, UInt32 tLength)
  91. {
  92. //StringHandle    theString;
  93. long    selStart, selEnd;
  94. const short    nullstr = 0;    // otherwise IC 1.1 will crash (doesn't like odd-aligned strings)
  95. //ICError    err;
  96.  
  97. selStart = 0L;
  98. selEnd = tLength;
  99.  
  100. return ICLaunchURL(inst, (ConstStr255Param)&nullstr, s, selEnd, &selStart, &selEnd);
  101. }
  102.  
  103. ICError MyICCLaunchURLText(ICInstance inst, Ptr s, UInt32 tLength)
  104. {
  105. //StringHandle    theString;
  106. long    selStart, selEnd;
  107. const short    nullstr = 0;    // otherwise IC 1.1 will crash (doesn't like odd-aligned strings)
  108. //ICError    err;
  109.  
  110. selStart = 0L;
  111. selEnd = tLength;
  112.  
  113. return ICCLaunchURL((internetConfigurationComponent)inst, (ConstStr255Param)&nullstr, s, selEnd, &selStart, &selEnd);
  114. }
  115.  
  116. #pragma segment Init
  117.  
  118. ICError MyICInit(ICInstance *inst, OSType creator)
  119. {
  120. ICError    err;
  121.  
  122. if (err = ICStart(inst, creator))
  123.     *inst = nil;
  124. else
  125.     err = ICFindConfigFile(*inst, 0, nil);
  126. //UnloadSeg(ICStart);
  127. return err;
  128. }
  129.  
  130. ICError MyICInitNoSeg(ICInstance *inst, OSType creator)
  131. {
  132. ICError    err;
  133.  
  134. if (err = ICCStart((internetConfigurationComponent *)inst, creator))
  135.     *inst = nil;
  136. else
  137.     err = ICCFindConfigFile((internetConfigurationComponent)*inst, 0, nil);
  138. return err;
  139. }
  140.  
  141.  
  142. // check out the last #pragma segment !!!!!
  143.